package com.sky.controller;

import com.sky.entity.Address;
import com.sky.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/admin/user/address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @PostMapping
    public void addAddress(@RequestBody Address address) {
        addressService.save(address);
    }

    @GetMapping
    public List<Address> listVisible() {
        return addressService.listVisible();
    }

    @PutMapping
    public void updateAddress(@RequestBody Address address) {
        addressService.update(address);
    }

    @DeleteMapping("/{id}")
    public void deleteAddress(@PathVariable Long id) {
        addressService.delete(id);
    }
}
